#!/usr/bin/python3
# -*- coding: UTF-8 -*-


# fi   = git@gitlab.netflying.net:netflying/054-thepupsocks.com.git
# fi_d = filepath = G:/www/wangxiang/
# f    = 054-thepupsocks.com
# c.hot_fix_name = 

import os
from gitlab_map import site_map
import config as c

def git_clone(filepath, git_flow_open):
    domain_list = c.dirname_list
    gitflow = c.gitflow_list
    domain = []
    for i in domain_list:
        for k in gitflow:
            if k == i:
                domain.append(k)
    domain = domain_list
    for i in domain:
        name = i.lower()
        fi = site_map[name]
        fi_d = filepath
        try:
            f = fi.split('/')[1][:-4]
            # cmd = "cd /d %s && git clone %s " % (fi_d,fi)
            # print("cmd=", cmd)
            # os.system(cmd)

            # 提交分支
            # cmd = "cd /d %s\%s && git add . && git commit -m '礼盒配置提交' " % (fi_d, f)

            # 推送分支  （将当前分支推送到远程仓库，并且设置远程仓库的 hotfix/2024-03-11-giftBox 分支作为当前分支的上游分支）
            # cmd = "cd /d %s\%s && git push --set-upstream origin hotfix/2024-03-11-giftBox " % (fi_d, f)

            # 提交分支
            cmd = "cd /d %s\%s && git push" % (fi_d, f)

            # cmd = "cd /d %s\%s && git branch" % (fi_d, f)

            print("cmd=", cmd)
            os.system(cmd)
        except:
            print(fi + ' ***** 拉取失败 *****')

if __name__ == "__main__":
    batch_git_path = c.batch_git_path
    git_clone(batch_git_path, c.git_flow_check)
